package com.rc.object;

import java.io.Serializable;

import com.rc.activity.dao.tbl_Receipt;
import com.rc.util.Util;

public class ReceiptObj implements Serializable {

	public static final String[] keys = { "ReceiptID", "MerchantID",
			"OriginalTotal", "Discount", "Subtotal", "Tax", "CurrencyCode",
			"ExchangeRate", "ReportStatus", "PurchaseTime", "CreatedTime",
			"IsArchived", "IsOpened", "IsNew", "Memo", "ReceiptType",
			"MerchantCountry", "ReceiptImage", "UserID" };

	public static final String RECEIPT_ID = keys[0];
	public static final String MERCHANT_ID = keys[1];
	public static final String TOTAL = keys[2];
	public static final String DISCOUNT = keys[3];
	public static final String SUBTOTAL = keys[4];
	public static final String TAX = keys[5];
	public static final String CURRENCY_CODE = keys[6];
	public static final String EXCHANGE_RATE = keys[7];
	public static final String REPORTSTATUS = keys[8];
	public static final String PURCHASE_TIME = keys[9];
	public static final String CREATED_TIME = keys[10];
	public static final String IS_ARCHIVED = keys[11];
	public static final String IS_OPENED = keys[12];
	public static final String IS_NEW = keys[13];
	public static final String MEMO = keys[14];
	public static final String RECEIPT_TYPE = keys[15];
	public static final String MERCHANT_COUNTRY = keys[16];
	public static final String RECEIPT_IMAGE = keys[17];
	public static final String USER_ID = keys[18];

	public static tbl_Receipt getReceiptbyBaseObject(BaseObject baseObject) {
		tbl_Receipt objReceipt = new tbl_Receipt();
		long mReceiptID = baseObject.getParamLong(ReceiptObj.RECEIPT_ID);
		objReceipt.setReceiptID(mReceiptID);

		String mReceiptType = baseObject.getParam(ReceiptObj.RECEIPT_TYPE);
		objReceipt.setReceiptType(mReceiptType);

		String mCreateTime = baseObject.getParam(ReceiptObj.CREATED_TIME);
		objReceipt.setCreatedTime(mCreateTime);
		// mCreateTime = Util.formateDateFromstring("yyyy-MM-dd'T'HH:mm:ss.SSS",
		// "yyyy-MM-dd-HH-mm-ss-SSS", mCreateTime);
		//
		// long mCreatedInt = Util.parseDateForReceipt(mCreateTime);
		// if (mCreateTime != null) {
		// objReceipt.setFilterDate(Long.valueOf(mCreateTime));
		// }

		String mPurChase_Time = baseObject.getParam(ReceiptObj.PURCHASE_TIME);
		mPurChase_Time = Util.formateDateFromstring("yyyy-MM-dd'T'HH:mm",
				"dd-MM-yyyy", mPurChase_Time);
		objReceipt.setPurchaseTime(mPurChase_Time);

		long mMerChantID = baseObject.getParamLong(MerchantObj.MERCHANT_ID);
		objReceipt.setMerchantID(mMerChantID);
		objReceipt.setDiscount(Util.formatStringFloat(Util
				.convertFloat(baseObject.getParam(ReceiptObj.DISCOUNT))));

		objReceipt.setTotal(Util.formatStringFloat(Util.convertFloat(baseObject
				.getParam(ReceiptObj.TOTAL))));

		objReceipt.setSubtotal(Util.formatStringFloat(Util
				.convertFloat(baseObject.getParam(ReceiptObj.SUBTOTAL))));

		objReceipt.setTax(Util.formatStringFloat(Util.convertFloat(baseObject
				.getParam(ReceiptObj.TAX))));

		String mCurrencyCode = "";
		mCurrencyCode = baseObject.getParam(ReceiptObj.CURRENCY_CODE);
		objReceipt.setCurrencyCode(mCurrencyCode);

		float mExchange_Rate = 0;
		if (!"null".equals(baseObject.getParam(ReceiptObj.EXCHANGE_RATE))
				&& baseObject.getParam(ReceiptObj.EXCHANGE_RATE) != null) {
			mExchange_Rate = Util.convertFloat(baseObject
					.getParam(ReceiptObj.EXCHANGE_RATE));
		} else {
		}
		objReceipt.setExchangeRate(mExchange_Rate);

		int mIs_Archived = 0;
		mIs_Archived = baseObject.getParamInt(ReceiptObj.IS_ARCHIVED);
		objReceipt.setIsArchived(mIs_Archived);

		int mIs_Open = 0;
		mIs_Open = baseObject.getParamInt(ReceiptObj.IS_OPENED);
		objReceipt.setIsOpened(mIs_Open);

		int mIs_New = 0;
		mIs_New = baseObject.getParamInt(ReceiptObj.IS_NEW);
		objReceipt.setIsArchived(mIs_New);

		String mMemo = "";
		mMemo = baseObject.getParam(ReceiptObj.MEMO);
		objReceipt.setInfo(mMemo);

		String mMerchantCountry = "";
		mMerchantCountry = baseObject.getParam(ReceiptObj.MERCHANT_COUNTRY);
		objReceipt.setMerchantCountry(mMerchantCountry);
		objReceipt.setIsCreate("");
		objReceipt.setIsDelete("");
		objReceipt.setIsUpdate("");
		objReceipt.setReceiptImage(baseObject
				.getParam(ReceiptObj.RECEIPT_IMAGE));
		objReceipt.setUserID(baseObject.getParamLong(USER_ID));
		return objReceipt;
	}

	/**
	 * Version Serializable
	 */
	private static final long serialVersionUID = 1L;

	private long ReceiptID;
	private String ReceiptType;
	private String MerchantName;
	private String MerchantLogo;
	private long MerchantID;
	private String Total;
	private String dateTime;
	private String Address;
	private String SubTotal;
	private String Discount;
	private String Tax;
	private String CurrencyCode;
	private String ReceiptImage;
	private int IsOpen;

	private boolean checkbox = false;

	public String getReceiptImage() {
		return ReceiptImage;
	}

	public int getIsOpen() {
		return IsOpen;
	}

	public void setIsOpen(int isOpen) {
		IsOpen = isOpen;
	}

	public void setReceiptImage(String receiptImage) {
		ReceiptImage = receiptImage;
	}

	public long getReceiptID() {
		return ReceiptID;
	}

	public String getCurrencyCode() {
		return CurrencyCode;
	}

	public void setCurrencyCode(String currencyCode) {
		CurrencyCode = currencyCode;
	}

	public void setReceiptID(long receiptID) {
		ReceiptID = receiptID;
	}

	public String getReceiptType() {
		return ReceiptType;
	}

	public void setReceiptType(String receiptType) {
		ReceiptType = receiptType;
	}

	public String getMerchantName() {
		return MerchantName;
	}

	public void setMerchantName(String merchantName) {
		MerchantName = merchantName;
	}

	public String getMerchantLogo() {
		return MerchantLogo;
	}

	public void setMerchantLogo(String merchantLogo) {
		MerchantLogo = merchantLogo;
	}

	public long getMerchantID() {
		return MerchantID;
	}

	public void setMerchantID(long merchantID) {
		MerchantID = merchantID;
	}

	public String getTotal() {
		return Total;
	}

	public void setTotal(String total) {
		Total = total;
	}

	public String getDateTime() {
		return dateTime;
	}

	public void setDateTime(String dateTime) {
		this.dateTime = dateTime;
	}

	public String getAddress() {
		return Address;
	}

	public void setAddress(String address) {
		Address = address;
	}

	public String getSubTotal() {
		return SubTotal;
	}

	public void setSubTotal(String subTotal) {
		SubTotal = subTotal;
	}

	public String getDiscount() {
		return Discount;
	}

	public void setDiscount(String discount) {
		Discount = discount;
	}

	public String getTax() {
		return Tax;
	}

	public void setTax(String tax) {
		Tax = tax;
	}

	public boolean isCheckbox() {
		return checkbox;
	}

	public void setCheckbox(boolean checkbox) {
		this.checkbox = checkbox;
	}

}
